﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MovieRental_Presentation.DataViews;
using MovieRental_Presentation.Helpers;
using MovieRental.Entities;
using MovieRental.Charts;

namespace MovieRental_Presentation
{
	public partial class Statistics
	{
        private StatisticsDataView _dataView;

		public Statistics()
		{
			this.InitializeComponent();
           

			// Insert code required on object creation below this point.
		}

        private void addCartDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            cartDiscountGrid.Visibility = Visibility.Visible;
        }

        private void cancelCartDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            cartDiscountGrid.Visibility = Visibility.Collapsed;
        }

        private void cancelPersonalDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            personalDiscountGrid.Visibility = Visibility.Collapsed;
        }

        private void addPersonalDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            personalDiscountGrid.Visibility = Visibility.Visible;
        }

        private void applyCartDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            ComponentManager.Instance.CartDiscountComponent.AddDiscountRule(_dataView.Quantity, cartDiscountSlider.Value);
            cartDiscountGrid.Visibility = Visibility.Collapsed;
        }

        private void applyPersonalDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            ComponentManager.Instance.PersonalDiscountComponent.AddDiscountRule(_dataView.SpentMoney, personalDiscountSlider.Value);
            personalDiscountGrid.Visibility = Visibility.Collapsed;
        }

        private void deleteCartDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            if (cartDiscountsDataGrid.SelectedItem != null)
                ComponentManager.Instance.CartDiscountComponent.Delete((CartDiscountInfo)cartDiscountsDataGrid.SelectedItem);
        }

        private void deletePersonalDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            if (personalDiscountsDataGrid.SelectedItem != null)
                ComponentManager.Instance.PersonalDiscountComponent.Delete((PersonalDiscountInfo)personalDiscountsDataGrid.SelectedItem);
        }

        private void backButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	NavigationService.GoBack();
        }

        private void dashboardButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	NavigationService.Navigate(new Dashboard());
        }

        private void customersButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	NavigationService.Navigate(new Customers());
        }

        private void moviesButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	NavigationService.Navigate(new Movies());
        }

        private void statisticsPage_Loaded(object sender, RoutedEventArgs e)
        {
            _dataView = new StatisticsDataView(chartCanvas);
            DataContext = _dataView;
        }

        




 

  
	}
}